#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File    :   App_WriteDataById_0x2E_test.py
@Time    :   2022/9/14 13:31:28
@Author  :   YangLiang
@Version :   1.0
@Contact :   yangliang@chengtech.com
@License :   (C)Copyright 2022-2025
@Desc    :   None
'''

# here put the import lib
from gettext import find
# from lib2to3.pgen2 import driver
from re import X
from urllib import response
from pytest_assume.plugin import assume

import pytest
import logging
import time
import requests
from sympy import I
# from sympy import assuming
from commDriver.TS_CAN import *
import allure
import sys
from collections.abc import Iterable

from sqlalchemy import false
sys.dont_write_bytecode = True
import Set_up


class Test_DTCSnapshotRecordNUM_phy(object):

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]

   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_01_Default_Phy(self, action, BCMPower_Gear, Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x01]
      if dtcNumber == [0xAC,0xD1,0x78] or dtcNumber == [0xAC,0xD2,0x78] or dtcNumber == [0xAC,0xE6,0x55]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      time.sleep(0.5)
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDS', 'ClearFault')

   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_01_Extended_Phy(self, action, BCMPower_Gear, Driver, dtcNumber,dtcName):
      iStep = 1
      time.sleep(0.5)
      req =  [0x19,0x06] + dtcNumber + [0x01]
      if dtcNumber == [0xAC,0xD1,0x78] or dtcNumber == [0xAC,0xD2,0x78] or dtcNumber == [0xAC,0xE6,0x55]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDS', 'ClearFault')

   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber, dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_02_Default_Phy(self, action, BCMPower_Gear, Driver, dtcNumber, dtcName):
      iStep = 1
      time.sleep(0.5)
      req =  [0x19,0x06] + dtcNumber + [0x02]
      resp = [0x7F, 0X19,0x31]
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_02")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDS', 'ClearFault')

   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber, dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_02_Extended_Phy(self, action, BCMPower_Gear, Driver, dtcNumber, dtcName):
      iStep = 1
      time.sleep(0.5)
      req =  [0x19,0x06] + dtcNumber + [0x02]
      resp = [0x7F, 0X19,0x31]
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_02")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDS', 'ClearFault')


   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_FF_Default_Phy(self, action, BCMPower_Gear, Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0xFF]
      if dtcNumber == [0xAC,0xD1,0x78] or dtcNumber == [0xAC,0xD2,0x78] or dtcNumber == [0xAC,0xE6,0x55]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      time.sleep(0.5)
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_FF")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDS', 'ClearFault')


   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with physical addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_FF_Extended_Phy(self, action, BCMPower_Gear, Driver, dtcNumber,dtcName):
      iStep = 1
      time.sleep(0.5)
      req =  [0x19,0x06] + dtcNumber + [0xFF]
      if dtcNumber == [0xAC,0xD1,0x78] or dtcNumber == [0xAC,0xD2,0x78] or dtcNumber == [0xAC,0xE6,0x55]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_FF")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDS', 'ClearFault')



   @allure.severity('normal')
   @allure.description('Test request DTCStatusMask with no fault in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_occurrence_counter_Multiple_failures_Defaul_Phy(self, action, BCMPower_Gear, Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电源电压为8V
      iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x01,0x00], 0, iStep)

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep)    
      
      # ECU下电再次上电
      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      logging.info('Wait 1s')
      time.sleep(1)
      logging.info('Wait 1s')

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep)
      
      # 设置电源电压为8V
      iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x01,0x00], 0, iStep)

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep)

      with allure.step(f'step{iStep}:重复产生故障并消除 5次'):
         for i in range(5):
            # 设置电源电压为8V
            iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x02+i,0], 0, iStep)

            # 设置电源电压为12V
            iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x02+i,0], 0, iStep)    
          
      # ECU下电再次上电
      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      time.sleep(1)
      logging.info('Wait 1s')

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep)

      # 设置电源电压为8V
      iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x02,0x09], [0x59,0x02,0x09,0xAC,0xCF,0x16,0x09], 0, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x01,0x00], 0, iStep)
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
      # 重启ECU
      iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep)
      # 设置电源电压为12V
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 0, iStep)



   @allure.severity('normal')
   @allure.description('Test request DTCStatusMask with no fault in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_occurrence_counter_Multiple_failures_Extended_Phy(self, action, BCMPower_Gear, Driver):
      iStep = 1
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x00], 3, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电源电压为18V
      iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 0, iStep)

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x01,0x00], 0, iStep)    
      
      # ECU下电再次上电
      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      time.sleep(1)
      logging.info('Wait 1s')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x00], 3, iStep)
      
      # 设置电源电压为18V
      iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 0, iStep)

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x01,0x00], 0, iStep)

      with allure.step(f'step{iStep}:重复产生故障并消除 3次'):
         for i in range(3):
            # 设置电源电压为18V
            iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x02+i,0x00], 0, iStep)

            # 设置电源电压为12V
            iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x02+i,0x00], 0, iStep)    
          
      # ECU下电再次上电
      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      time.sleep(1.5)
      logging.info('Wait 1s')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x00], 3, iStep)
      # 设置电源电压为18V
      iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x02,0x09], [0x59,0x02,0x09,0xAC,0xCE,0x17,0x09], 0, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 0, iStep)
      # 重启ECU
      iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
      time.sleep(1.5)
      logging.info('Wait 1.5s')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 3, iStep)
      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x00], 0, iStep)



   @allure.severity('normal')
   @allure.description('Test request DTCStatusMask with no fault in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_occurrence_counter255_Multiple_failures_Default_Phy(self, action, BCMPower_Gear, Driver):
      iStep = 1
      time.sleep(0.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x00], 1, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电源电压为18V
      iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 0, iStep)

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x01,0x00], 0, iStep)    
      
      # ECU下电再次上电
      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      time.sleep(1)
      logging.info('Wait 1s')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x0], 1, iStep)
      
      # 设置电源电压为18V
      iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 0, iStep)

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x01,0x00], 0, iStep)

      with allure.step(f'step{iStep}:重复产生故障并消除重启256次'):
         for i in range(256):
            # 设置电源电压为18V
            iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)
            if i < 254:
               iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x02+i,0x00], 0, iStep)
            else:
               iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0xFF,0x00], 0, iStep)
            # 设置电源电压为12V
            iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
            if i < 254:
               iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x02+i,0x00], 0, iStep)
            else:
               iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0xFF,0x00], 0, iStep)    
            # # ECU下电再次上电
            # iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
            # time.sleep(1.5)
            # logging.info('Wait 1.5s')
            # if i < 252:
            #    iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x03+i,0x00], 0, iStep)
            # else:
            #    iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0xFF,0x00], 0, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0xFF,0x00], 1, iStep)

      # 设置电源电压为18V
      iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x02,0x09], [0x59,0x02,0x09,0xAC,0xCE,0x17,0x09], 0, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0xFF,0x00], 0, iStep)
      # 重启ECU
      iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 3, iStep)
      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x00], 0, iStep)



   
   @allure.severity('normal')
   @allure.description('Test request DTCStatusMask with no fault in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCAgingCounter_Defaul_Phy(self, action, BCMPower_Gear, Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电源电压为8V
      iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x01,0x00], 0, iStep)

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep)    

      with allure.step(f'step{iStep}:重启3次'):
         iStep += 1
         for i in range(3):
            # ECU下电再次上电
            iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 0, iStep)    
          
      # 设置电源电压为8V
      iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x02,0x09], [0x59,0x02,0x09,0xAC,0xCF,0x16,0x09], 0, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x01,0x00], 0, iStep)
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep)
      # 重启ECU
      iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep)
      # 设置电源电压为12V
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 0, iStep)



   @allure.severity('normal')
   @allure.description('Test request DTCStatusMask with no fault in default session with function addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCAgingCounter40_Defaul_Phy(self, action, BCMPower_Gear, Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep, False, 'UDS', 'ClearFault')
      
      # 设置电源电压为8V
      iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x01,0x00], 0, iStep)

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep)    

      with allure.step(f'step{iStep}:重启41次'):
         iStep += 1
         for i in range(45):
            # ECU下电再次上电
            # iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
            if i < 41:
               iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep) 
            else:
               iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep)   
          
      # 重启ECU
      iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep)



class Test_DTCSnapshotRecordNUM_Fun(object):

   ids = ["Request {0}".format(binascii.b2a_hex(bytearray(dtcNumber), ' '), dtcName) for dtcNumber, dtcName in Set_up.DTC_list]

   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_01_Default_Fun(self, action, BCMPower_Gear, Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0x01]
      if dtcNumber == [0xAC,0xD1,0x78] or dtcNumber == [0xAC,0xD2,0x78] or dtcNumber == [0xAC,0xE6,0x55]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      time.sleep(0.5)
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDSFun', 'ClearFault')

   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_01_Extended_Fun(self, action, BCMPower_Gear, Driver, dtcNumber,dtcName):
      iStep = 1
      time.sleep(0.5)
      req =  [0x19,0x06] + dtcNumber + [0x01]
      if dtcNumber == [0xAC,0xD1,0x78] or dtcNumber == [0xAC,0xD2,0x78] or dtcNumber == [0xAC,0xE6,0x55]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}:{dtcNumber}]  by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_01")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun', 'ClearFault')

   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber, dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_02_Default_Fun(self, action, BCMPower_Gear, Driver, dtcNumber, dtcName):
      iStep = 1
      time.sleep(0.5)
      req =  [0x19,0x06] + dtcNumber + [0x02]
      resp = [0x7F, 0X19,0x31]
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_02")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDSFun', 'ClearFault')

   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber, dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_02_Extended_Fun(self, action, BCMPower_Gear, Driver, dtcNumber, dtcName):
      iStep = 1
      time.sleep(0.5)
      req =  [0x19,0x06] + dtcNumber + [0x02]
      resp = [0x7F, 0X19,0x31]
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_02")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun', 'ClearFault')


   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_FF_Default_Fun(self, action, BCMPower_Gear, Driver, dtcNumber,dtcName):
      iStep = 1
      req =  [0x19,0x06] + dtcNumber + [0xFF]
      if dtcNumber == [0xAC,0xD1,0x78] or dtcNumber == [0xAC,0xD2,0x78] or dtcNumber == [0xAC,0xE6,0x55]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      time.sleep(0.5)
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_FF")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 1, iStep, False, 'UDSFun', 'ClearFault')


   @allure.severity('normal')
   @allure.description('Test Report DTC Extended Data Record by DTC Number with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   @pytest.mark.parametrize('dtcNumber,dtcName', Set_up.DTC_list, ids=ids)
   def test_NoFault_DTCExtended_Data_FF_Extended_Fun(self, action, BCMPower_Gear, Driver, dtcNumber,dtcName):
      iStep = 1
      time.sleep(0.5)
      req =  [0x19,0x06] + dtcNumber + [0xFF]
      if dtcNumber == [0xAC,0xD1,0x78] or dtcNumber == [0xAC,0xD2,0x78] or dtcNumber == [0xAC,0xE6,0x55]:
         resp = [0x59,0x06] + dtcNumber
      else:
         resp = [0x59,0x06] + dtcNumber + [0x00]
      logging.info(f"Test [{dtcName}] by SID_0x19-Subfunction_0x06-DTCExtendedDataRecordNumb_FF")
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, req, resp, 3, iStep, False, 'UDSFun', 'ClearFault')



   @allure.severity('normal')
   @allure.description('Test request DTCStatusMask with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_occurrence_counter_Multiple_failures_Defaul_Fun(self, action, BCMPower_Gear, Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电源电压为8V
      iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')    
      
      # ECU下电再次上电
      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      logging.info('Wait 1s')
      time.sleep(1)
      logging.info('Wait 1s')

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep, False, 'UDSFun')
      
      # 设置电源电压为8V
      iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')

      with allure.step(f'step{iStep}:重复产生故障并消除 5次'):
         for i in range(5):
            # 设置电源电压为8V
            iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x02+i,0], 0, iStep, False, 'UDSFun')

            # 设置电源电压为12V
            iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x02+i,0], 0, iStep, False, 'UDSFun')    
          
      # ECU下电再次上电
      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      time.sleep(1)
      logging.info('Wait 1s')

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep, False, 'UDSFun')

      # 设置电源电压为8V
      iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x02,0x09], [0x59,0x02,0x09,0xAC,0xCF,0x16,0x09], 0, iStep, False, 'UDSFun')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
      # 重启ECU
      iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep, False, 'UDSFun')
      # 设置电源电压为12V
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep, False, 'UDSFun')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 0, iStep, False, 'UDSFun')



   @allure.severity('normal')
   @allure.description('Test request DTCStatusMask with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_occurrence_counter_Multiple_failures_Extended_Fun(self, action, BCMPower_Gear, Driver):
      iStep = 1
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x00], 3, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电源电压为18V
      iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')    
      
      # ECU下电再次上电
      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      time.sleep(1)
      logging.info('Wait 1s')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x00], 3, iStep, False, 'UDSFun')
      
      # 设置电源电压为18V
      iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')

      with allure.step(f'step{iStep}:重复产生故障并消除 3次'):
         for i in range(3):
            # 设置电源电压为18V
            iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x02+i,0x00], 0, iStep, False, 'UDSFun')

            # 设置电源电压为12V
            iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x02+i,0x00], 0, iStep, False, 'UDSFun')    
          
      # ECU下电再次上电
      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      time.sleep(1.5)
      logging.info('Wait 1s')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x00], 3, iStep, False, 'UDSFun')
      # 设置电源电压为18V
      iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x02,0x09], [0x59,0x02,0x09,0xAC,0xCE,0x17,0x09], 0, iStep, False, 'UDSFun')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')
      # 重启ECU
      iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
      time.sleep(1.5)
      logging.info('Wait 1.5s')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 3, iStep, False, 'UDSFun')
      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep, False, 'UDSFun')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x00], 0, iStep, False, 'UDSFun')



   @allure.severity('normal')
   @allure.description('Test request DTCStatusMask with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCS_occurrence_counter255_Multiple_failures_Default_Fun(self, action, BCMPower_Gear, Driver):
      iStep = 1
      time.sleep(0.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x00], 1, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电源电压为18V
      iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')    
      
      # ECU下电再次上电
      iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
      time.sleep(1)
      logging.info('Wait 1s')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x00], 1, iStep, False, 'UDSFun')
      
      # 设置电源电压为18V
      iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)
      
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')

      with allure.step(f'step{iStep}:重复产生故障并消除重启256次'):
         for i in range(256):
            # 设置电源电压为18V
            iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)
            if i < 254:
               iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x02+i,0x00], 0, iStep, False, 'UDSFun')
            else:
               iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0xFF,0x00], 0, iStep, False, 'UDSFun')
            # 设置电源电压为12V
            iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
            if i < 254:
               iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x02+i,0x00], 0, iStep, False, 'UDSFun')
            else:
               iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0xFF,0x00], 0, iStep, False, 'UDSFun')    
            # # ECU下电再次上电
            # iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
            # time.sleep(1.5)
            # logging.info('Wait 1.5s')
            # if i < 252:
            #    iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0x03+i,0x00], 0, iStep, False, 'UDSFun')
            # else:
            #    iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0xFF,0x00], 0, iStep, False, 'UDSFun')

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x08,0x01,0xFF,0x00], 1, iStep, False, 'UDSFun')

      # 设置电源电压为18V
      iStep = Driver['CAN'].SetVolt(Driver, 18, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x02,0x09], [0x59,0x02,0x09,0xAC,0xCE,0x17,0x09], 0, iStep, False, 'UDSFun')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0xFF,0x00], 0, iStep, False, 'UDSFun')
      # 重启ECU
      iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x09,0x01,0x01,0x00], 3, iStep, False, 'UDSFun')
      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep, False, 'UDSFun')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCE,0x17,0x01], [0x59,0x06,0xAC,0xCE,0x17,0x00], 0, iStep, False, 'UDSFun')



   
   @allure.severity('normal')
   @allure.description('Test request DTCStatusMask with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCAgingCounter_Defaul_Fun(self, action, BCMPower_Gear, Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电源电压为8V
      iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')    

      with allure.step(f'step{iStep}:重启3次'):
         iStep += 1
         for i in range(3):
            # ECU下电再次上电
            iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
            iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 0, iStep, False, 'UDSFun')    
          
      # 设置电源电压为8V
      iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x02,0x09], [0x59,0x02,0x09,0xAC,0xCF,0x16,0x09], 0, iStep, False, 'UDSFun')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')
      # 重启ECU
      iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep, False, 'UDSFun')
      # 设置电源电压为12V
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x14,0xFF,0xFF,0xFF], [0x54], 0, iStep, False, 'UDSFun')
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 0, iStep, False, 'UDSFun')



   @allure.severity('normal')
   @allure.description('Test request DTCStatusMask with no fault in default session with functional addressing')
   @allure.testcase('Https://chengtech.pingcode.com/testhub/libraries/627628a182973e6c3aa153a4/cases')
   def test_DTCAgingCounter40_Defaul_Fun(self, action, BCMPower_Gear, Driver):
      iStep = 1
      logging.info('Wait 1.5s')
      time.sleep(1.5)
      iStep,uds_resp, size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep, False, 'UDSFun', 'ClearFault')
      
      # 设置电源电压为8V
      iStep = Driver['CAN'].SetVolt(Driver, 8, 1.5, iStep)

      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x09,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')

      # 设置电源电压为12V
      iStep = Driver['CAN'].SetVolt(Driver, 12, 1.5, iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')    

      with allure.step(f'step{iStep}:重启41次'):
         iStep += 1
         for i in range(45):
            # ECU下电再次上电
            # iStep = Driver['CAN'].restartMRR_Power(Driver,iStep)
            if i < 41:
               iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep, False, 'UDSFun') 
            else:
               iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x08,0x01,0x01,0x00], 0, iStep, False, 'UDSFun')   
          
      # 重启ECU
      iStep = Driver['CAN'].restartMRR_11(Driver,iStep)
      iStep,uds_resp,size = Driver['CAN'].checkReqResp(Driver, [0x19,0x06,0xAC,0xCF,0x16,0x01], [0x59,0x06,0xAC,0xCF,0x16,0x00], 1, iStep, False, 'UDSFun')

